home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_10 / saks / common.h < prev    next >
C/C++ Source or Header  |  1994-08-08  |  741b  |  36 lines

  1. Listing 4 - A abstract base class for objects in generic containers
  2.  
  3. //
  4. // common.h - a common abstract type for objects placed in containers
  5. //
  6.  
  7. #ifndef COMMON_H_INCLUDED
  8. #define COMMON_H_INCLUDED
  9.  
  10. #include <iostream.h>
  11.  
  12. class common
  13.     {
  14. public:
  15.     virtual const common &
  16.         operator=(const common &c) = 0;
  17.     virtual common *dup() const = 0;
  18.     virtual size_t size() const = 0;
  19.     virtual ostream &write(ostream &s) const = 0;
  20.     virtual istream &read(istream &s) = 0;
  21.     virtual ~common() { }
  22.     };
  23.  
  24. inline ostream &operator<<(ostream &os, const common &c)
  25.     {
  26.     return c.write(os);
  27.     }
  28.  
  29. inline istream &operator>>(istream &os, common &c)
  30.     {
  31.     return c.read(os);
  32.     }
  33.  
  34. #endif
  35.  
  36.